package com.yu.util;

import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.Map;

import org.apache.poi.util.SystemOutLogger;

import java.util.HashMap;

public class DateUtil {

    public static final String LIVE_TIME_FORMAT = "MM/dd HH:mm";

	public static final String COMMON_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
    public static final String MEET_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm";

	public static final String STANDARD_DATE_TIME_FORMAT = "yyyy/MM/dd HH:mm";

	public static final String COMMON_DATE_FORMAT = "yyyy-MM-dd";
	
	public static final String COMMON_TIME_FORMAT = "HH:mm:ss";

	public static final String COMMON_WX_TEMP_DATE_FORMAT = "yyyy年MM月dd日 HH时mm分";


	public static final String COMMON_SHORT_DATE_FORMAT_FOR_CHINESE = "M月d日";

    public static final String COMMON_SHORT_DATE_FORMAT_FOR_CHINESE1 = "yyyy年MM月dd日";

    public static final String COMMON_LONG_DATE_FORMAT_FOR_CHINESE1 = "M月d日HH点mm分";
	
	public static final String COMMON_SHORT_TIME_FORMAT = "HH:mm";
	
	public static final String COMMON_DATE_TIME_INDEX_FORMAT = "yyyyMMddHHmmss";
	
	public static final String COMMON_DATE_INDEX_FORMAT = "yyyyMMdd";
	
	public static final String COMMON_TIME_INDEX_FORMAT = "HHmmss";
	
	public static final String COMMON_DAY_FORMAT = "E";

    public static final SimpleDateFormat liveDateTimeFormat = new SimpleDateFormat(LIVE_TIME_FORMAT);
    public static final SimpleDateFormat wxDateTimeFormat = new SimpleDateFormat(COMMON_WX_TEMP_DATE_FORMAT);

	public static final SimpleDateFormat commonDateTimeFormat = new SimpleDateFormat(COMMON_DATE_TIME_FORMAT);

    public static final SimpleDateFormat meetDateTimeFormat = new SimpleDateFormat(MEET_DATE_TIME_FORMAT);

	public static final SimpleDateFormat standardDateTimeFormat = new SimpleDateFormat(STANDARD_DATE_TIME_FORMAT);

	public static final SimpleDateFormat commonDateFormat = new SimpleDateFormat(COMMON_DATE_FORMAT);
	
	public static final SimpleDateFormat commonTimeFormat = new SimpleDateFormat(COMMON_TIME_FORMAT);
	
	public static final SimpleDateFormat commonShortDateFormatForChinese = new SimpleDateFormat(COMMON_SHORT_DATE_FORMAT_FOR_CHINESE);

    public static final SimpleDateFormat commonShortDateFormatForChinese1 = new SimpleDateFormat(COMMON_SHORT_DATE_FORMAT_FOR_CHINESE1);

    public static final SimpleDateFormat commonLongDateFormatForChinese1 = new SimpleDateFormat(COMMON_LONG_DATE_FORMAT_FOR_CHINESE1);

	public static final SimpleDateFormat commonShortTimeFormat = new SimpleDateFormat(COMMON_SHORT_TIME_FORMAT);
	
	public static final SimpleDateFormat commonDateTimeIndexFormat = new SimpleDateFormat(COMMON_DATE_TIME_INDEX_FORMAT);
	
	public static final SimpleDateFormat commonDateIndexFormat = new SimpleDateFormat(COMMON_DATE_INDEX_FORMAT);
	
	public static final SimpleDateFormat commonTimeIndexFormat = new SimpleDateFormat(COMMON_TIME_INDEX_FORMAT);
	
	public static final SimpleDateFormat commonDayFormat = new SimpleDateFormat(COMMON_DAY_FORMAT);



    public static  String getStringUTC(Long date){
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(date);
        //2、取得时间偏移量：
        int zoneOffset = cal.get(java.util.Calendar.ZONE_OFFSET);
        //3、取得夏令时差：
        int dstOffset = cal.get(java.util.Calendar.DST_OFFSET);
        //4、从本地时间里扣除这些差量，即可以取得UTC时间：
        cal.add(java.util.Calendar.MILLISECOND, -(zoneOffset + dstOffset));
        return commonDateFormat.format(new Date(cal.getTimeInMillis()))+"T"+commonTimeFormat.format(new Date(cal.getTimeInMillis()))+"Z";
    }
	/**
     * 获取现在时间
     * 
     * @return返回字符串格式 yyyyMMddHHmmss
     */
    public static String getStringDateTime() {
        Date currentTime = new Date();
        return commonDateTimeIndexFormat.format(currentTime);
    }


    /**
     * 获取现在时间
     * 
     * @return 返回短时间字符串格式yyyy-MM-dd
     */
    public static String getStringDate() {
    	Date currentTime = new Date();
        return commonDateFormat.format(currentTime);
    }
    

    /**
     * 获取现在时间
     * 
     * @return 返回短时间字符串格式yyyy-MM-ddTMM-dd
     */
    public static String getStringDateForH5() {
    	Date currentTime = new Date();
        return commonDateFormat.format(currentTime) +"T"+ commonShortTimeFormat.format(currentTime);
    }
    
    /**
     * 获取现在时间
     * 
     * @return 返回短时间字符串格式yyyy-MM-ddTMM-dd
     */
    public static String getStringDateForH5(long time) {
    	Date currentTime = new Date(time);
        return commonDateFormat.format(currentTime) +"T"+ commonShortTimeFormat.format(currentTime);
    }

    /**
     * 获取时间 小时:分:秒 HH:mm:ss
     * 
     * @return
     */
    public static String getStringTime() {
    	Date currentTime = new Date();
        return commonTimeFormat.format(currentTime);
    }

    /**
     * 将长时间格式字符串转换为时间 yyyy-MM-dd HH:mm:ss
     * 
     * @param strDate
     * @return
     */
    public static Date stringToDateTime(String strDate) {
        ParsePosition pos = new ParsePosition(0);
        return commonDateTimeFormat.parse(strDate, pos);
    }

    /**
     * 将长时间格式时间转换为字符串 yyyy-MM-dd HH:mm:ss
     * 
     * @param dateTime
     * @return
     */
    public static String dateTimeToString(Date dateTime) {
        return commonDateTimeFormat.format(dateTime);
    }

    /**
     * 将短时间格式时间转换为字符串 yyyy-MM-dd
     * 
     * @param dateDate
     * @param
     * @return
     */
    public static String dateToString(Date dateDate) {
    	return commonDateFormat.format(dateDate);
    }

    /**
     * 将短时间格式字符串转换为时间 yyyy-MM-dd
     * 
     * @param strDate
     * @return
     */
    public static Date stringToDate(String strDate) {
    	ParsePosition pos = new ParsePosition(0);
        return commonDateFormat.parse(strDate, pos);
    }

    public static Date stringToDate1(String strDate) {
        ParsePosition pos = new ParsePosition(0);
        return commonDateFormat.parse(strDate, pos);
    }
    
    /**
     * 得到天数
     */
    public static int getDay(Date dateTime) {
    	Calendar calendar = Calendar.getInstance();
    	calendar.setTime(dateTime);
    	return calendar.get(Calendar.DAY_OF_MONTH);
    }

    /**
     * 得到24小时制的小时数
     */
    public static int getHour(Date dateTime) {
    	Calendar calendar = Calendar.getInstance();
    	calendar.setTime(dateTime);
    	return calendar.get(Calendar.HOUR_OF_DAY);
    }

    /**
     * 得到分钟数
     * 
     * @return
     */
    public static int getMinute(Date dateTime) {
    	Calendar calendar = Calendar.getInstance();
    	calendar.setTime(dateTime);
    	return calendar.get(Calendar.MINUTE);
    }
    
    /**
     * 得到秒数
     * 
     * @return
     */
    public static int getSecond(Date dateTime) {
    	Calendar calendar = Calendar.getInstance();
    	calendar.setTime(dateTime);
    	return calendar.get(Calendar.SECOND);
    }

    /**
     * 判断是否润年
     * 
     * @param strDate
     * @return
     */
    public static boolean isLeapYear(String strDate) {
        /**
         * 详细设计： 1.被400整除是闰年，否则： 2.不能被4整除则不是闰年 3.能被4整除同时不能被100整除则是闰年
         * 3.能被4整除同时能被100整除则不是闰年
         */
        Date d = stringToDate(strDate);
        GregorianCalendar gc = (GregorianCalendar) Calendar.getInstance();
        gc.setTime(d);
        int year = gc.get(Calendar.YEAR);
        if ((year % 400) == 0)
            return true;
        else if ((year % 4) == 0) {
            if ((year % 100) == 0)
                return false;
            else
                return true;
        } else
            return false;
    }

    /**
     * 获取一个月的第一天
     * 
     * @param strDate
     * @return
     */
    public static String getStringFirstDateOfMonth(String strDate) {// yyyy-MM-dd
        String str = strDate.substring(0, 8);
        str += "01";
        return str;
    }
    
    /**
     * 获取一个月的最后一天
     * 
     * @param strDate
     * @return
     */
    public static String getStringLastDateOfMonth(String strDate) {// yyyy-MM-dd
    	Date d = stringToDate(strDate);
    	d = getLastDateOfMonth(d);
    	return commonDateFormat.format(d);
    }
    
    /**
     * 获取一个月的第一天
     * 
     * @param strDate
     * @return
     */
    public static Date getFirstDateOfMonth(String strDate) {// yyyy-MM-dd
    	Date dateTime = stringToDate(strDate);
        return getFirstDateOfMonth(dateTime);
    }
    
    /**
     * 获取一个月的最后一天
     * 
     * @param strDate
     * @return
     */
    public static Date getLastDateOfMonth(String strDate) {// yyyy-MM-dd
    	Date dateTime = stringToDate(strDate);
        return getLastDateOfMonth(dateTime);
    }
    
    /**
     * 获取一个月的第一天
     * 
     * @param dateTime
     * @return
     */
    public static Date getFirstDateOfMonth(Date dateTime) {
    	Calendar calendar = Calendar.getInstance();
    	calendar.setTime(dateTime);
    	calendar.set(Calendar.DAY_OF_MONTH, 1);
    	calendar.set(Calendar.MINUTE, 0);
    	calendar.set(Calendar.SECOND, 0);
    	calendar.set(Calendar.MILLISECOND, 0);
        return calendar.getTime();
    }
    
    /**
     * 获取一个月的最后一天
     * 
     * @param dateTime
     * @return
     */
    public static Date getLastDateOfMonth(Date dateTime) {
    	Calendar calendar = Calendar.getInstance();
    	calendar.setTime(dateTime);
        calendar.set(Calendar.DATE, 1);// 设为当前月的1号
        calendar.add(Calendar.MONTH, 1);// 加一个月，变为下月的1号
        calendar.add(Calendar.DATE, -1);// 减去一天，变为当月最后一天
    	calendar.set(Calendar.HOUR_OF_DAY, 23);
    	calendar.set(Calendar.MINUTE, 59);
    	calendar.set(Calendar.SECOND, 59);
    	calendar.set(Calendar.MILLISECOND, 999);
        return calendar.getTime();
    }
    
    /**
     * 获取一年的第一天
     * 
     * @param strDate
     * @return
     */
    public static Date getFirstDateOfYear(String strDate) {// yyyy-MM-dd
    	Date dateTime = stringToDate(strDate);
        return getFirstDateOfYear(dateTime);
    }
    
    /**
     * 获取一年的最后一天
     * 
     * @param strDate
     * @return
     */
    public static Date getLastDateOfYear(String strDate) {// yyyy-MM-dd
    	Date dateTime = stringToDate(strDate);
    	return getLastDateOfYear(dateTime);
    }
    
    /**
     * 获取一年的第一天
     * 
     * @param dateTime
     * @return
     */
    public static Date getFirstDateOfYear(Date dateTime) {
    	Calendar calendar = Calendar.getInstance();
    	calendar.setTime(dateTime);
    	calendar.set(Calendar.DAY_OF_YEAR, 1);
    	calendar.set(Calendar.HOUR_OF_DAY, 0);
    	calendar.set(Calendar.MINUTE, 0);
    	calendar.set(Calendar.SECOND, 0);
    	calendar.set(Calendar.MILLISECOND, 0);
        return calendar.getTime();
    }
    
    /**
     * 获取一年的最后一天
     * 
     * @param dateTime
     * @return
     */
    public static Date getLastDateOfYear(Date dateTime) {
    	Calendar calendar = Calendar.getInstance();
    	calendar.setTime(dateTime);
        calendar.set(Calendar.DAY_OF_MONTH, 31);
        calendar.set(Calendar.MONTH, Calendar.DECEMBER);
    	calendar.set(Calendar.HOUR_OF_DAY, 23);
    	calendar.set(Calendar.MINUTE, 59);
    	calendar.set(Calendar.SECOND, 59);
    	calendar.set(Calendar.MILLISECOND, 999);
        return calendar.getTime();
    }
    
    /**
     * 得到一个时间延后或前移几天的时间，nowdate为时间，delay为前移或后延的天数
     */
    public static String getStringNextDay(String strDate, int delay) {
        try {
            String mdate = "";
            Date d = stringToDate(strDate);
            long myTime = (d.getTime() / 1000) + delay * 24
                    * 60 * 60;
            d.setTime(myTime * 1000);
            mdate = commonDateFormat.format(d);
            return mdate;
        } catch (Exception e) {
            return "";
        }
    }
    
    /**
     * 得到一个时间延后或前移几天的时间，nowdate为时间，delay为前移或后延的天数
     */
    public static Date getDateNextDay(String strDate, int delay) {
    	Date d = stringToDate(strDate);
        long myTime = (d.getTime() / 1000) + delay * 24
                * 60 * 60;
        d.setTime(myTime * 1000);
        return d;
    }
    
    /**
     * 得到一个时间延后或前移几天的时间，data为时间，delay为前移或后延的天数
     */
    public static String getStringNextDay(Date dateTime, int delay) {
        try {
            String mdate = "";
            Date d = dateTime;
            long myTime = (d.getTime() / 1000) + delay * 24
                    * 60 * 60;
            d.setTime(myTime * 1000);
            mdate = commonDateFormat.format(d);
            return mdate;
        } catch (Exception e) {
            return "";
        }
    }

    /**
     * 减
     * @param date  时间
     * @param day 多少天
     * @return
     */
    public static Date getDateMinusDay(Date date, Integer day){
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.DATE, c.get(Calendar.DATE) - day);
        return c.getTime();
    }
    /**
     * 得到一个时间延后或前移几天的时间，data为时间，delay为前移或后延的天数
     */
    public static Date getDateNextDay(Date dateTime, int delay) {
    	Date d = dateTime;
        long myTime = (d.getTime() / 1000) + delay * 24
                * 60 * 60;
        d.setTime(myTime * 1000);
        return d;
    }
    
    /**
     * 得到一个时间延后或前移几月的时间，data为时间，delay为前移或后延的月数
     */
    public static Date getDateNextMonth(String strDate, int delay) {
    	Date dateTime = stringToDate(strDate);
        return getDateNextMonth(dateTime, delay);
    }
    
    /**
     * 得到一个时间延后或前移几月的时间，data为时间，delay为前移或后延的月数
     */
    public static Date getDateNextMonth(Date dateTime, int delay) {
    	Calendar calendar = Calendar.getInstance();
    	calendar.setTime(dateTime);
        calendar.add(Calendar.MONTH, delay);
    	return calendar.getTime();
    }
    
    /**
     * 得到一个时间延后或前移几月的时间，data为时间，delay为前移或后延的月数
     */
    public static String getStringNextMonth(String strDate, int delay) {
    	Date dateTime = stringToDate(strDate);
        return getStringNextMonth(dateTime, delay);
    }
    
    /**
     * 得到一个时间延后或前移几月的时间，data为时间，delay为前移或后延的月数
     */
    public static String getStringNextMonth(Date dateTime, int delay) {
        return dateToString(getDateNextMonth(dateTime, delay));
    }

    /**
     * 判断二个时间是否在同一个周
     * 
     * @param date1
     * @param date2
     * @return
     */
    public static boolean isSameWeekDates(Date date1, Date date2) {
        Calendar cal1 = Calendar.getInstance();
        Calendar cal2 = Calendar.getInstance();
        cal1.setTime(date1);
        cal2.setTime(date2);
        int subYear = cal1.get(Calendar.YEAR) - cal2.get(Calendar.YEAR);
        if (0 == subYear) {
            if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2
                    .get(Calendar.WEEK_OF_YEAR))
                return true;
        } else if (1 == subYear && 11 == cal2.get(Calendar.MONTH)) {
            // 如果12月的最后一周横跨来年第一周的话则最后一周即算做来年的第一周
            if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2
                    .get(Calendar.WEEK_OF_YEAR))
                return true;
        } else if (-1 == subYear && 11 == cal1.get(Calendar.MONTH)) {
            if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2
                    .get(Calendar.WEEK_OF_YEAR))
                return true;
        }
        return false;
    }

    /**
     * 产生周序列,即得到当前时间所在的年度是第几周
     * 
     * @return
     */
    public static String getSeqWeek() {
        Calendar c = Calendar.getInstance(Locale.CHINA);
        String week = Integer.toString(c.get(Calendar.WEEK_OF_YEAR));
        if (week.length() == 1)
            week = "0" + week;
        String year = Integer.toString(c.get(Calendar.YEAR));
        return year + week;
    }

    public static Map<Integer,Date> getMonDayOfMonth(int year, int month){
        Map<Integer,Date> map = new  HashMap<Integer,Date>();
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.YEAR, year);
        cal.set(Calendar.MONTH, month-1 );
        cal.set(Calendar.DATE, 1); // 设为第一天
        cal.set(Calendar.HOUR, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
        for(int i = 1 ; i<= lastDay;){
            if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY){
                //System.out.println(cal.get(Calendar.DAY_OF_WEEK_IN_MONTH));
                map.put(cal.get(Calendar.DAY_OF_WEEK_IN_MONTH), cal.getTime());
            }
            cal.set(Calendar.DAY_OF_MONTH, i++);
        }
        return map;

    }

    public static String forWeekString(Integer index){
        SimpleDateFormat sdf = new SimpleDateFormat(COMMON_SHORT_DATE_FORMAT_FOR_CHINESE);
        String result ="(";
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.DATE, 1); // 设为第一天
        if (index == 1){
            result += sdf.format(cal.getTime());
        }

        int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
        for(int i = 1 ; i<= lastDay;){
            if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){
                if (cal.get(Calendar.DAY_OF_WEEK_IN_MONTH)==index){
                    result +=  ("-" +  sdf.format(cal.getTime()));
                }

            }else if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY&&index!=1){
                if (cal.get(Calendar.DAY_OF_WEEK_IN_MONTH)==index-1){
                    result += sdf.format(cal.getTime());
                }
            }
            cal.set(Calendar.DAY_OF_MONTH, i++);
        }

        if (cal.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY){
            if (cal.get(Calendar.DAY_OF_WEEK_IN_MONTH)==index) {
                result += ("-" + sdf.format(cal.getTime()));
            }
        }
        result +=")";
        return result;
        //
    }

    /**
     *
     * @param year 年
     * @param month 月
     * @param date 日
     * @return
     */
    public static Date getCurrentMonday(Integer year,Integer month,Integer date){
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.YEAR, year);
        cal.set(Calendar.MONTH, month-1 );
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.DATE, date);
        if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY){
            return cal.getTime();
        }
        cal.set(Calendar.DATE, 1); // 设为第一天
        int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
        if (date>7){
            for(int i = date-7 ; date<= lastDay;){
                if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY){
                    //System.out.println(cal.get(Calendar.DAY_OF_WEEK_IN_MONTH));
                    if (cal.get(Calendar.DATE)>date -7){
                        return cal.getTime();
                    }
                }
                cal.set(Calendar.DAY_OF_MONTH, i++);
            }
        } else{
            for(int i = 1 ; i<= date;){
                if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY){
                    //System.out.println(cal.get(Calendar.DAY_OF_WEEK_IN_MONTH));
                    if (cal.get(Calendar.DATE)>date -7){
                        return cal.getTime();
                    }
                }
                cal.set(Calendar.DAY_OF_MONTH, i++);
            }

            cal.set(Calendar.MONTH, month-2 );
            int lastDay2 = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
            cal.set(Calendar.DAY_OF_MONTH, lastDay2);
            cal.set(Calendar.HOUR_OF_DAY, 0);
            cal.set(Calendar.MINUTE, 0);
            cal.set(Calendar.SECOND, 0);

            for(int j = lastDay2 ; j>= 21;){
                if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY){
                    return cal.getTime();
                }
                cal.set(Calendar.DAY_OF_MONTH, j--);
            }
        }

        return null;
    }

    /**
     * 将长时间格式字符串转换为时间 yyyy年MM月dd日HH点mm分
     *
     * @param strDate
     * @return
     */
    public static String dateToString2(String strDate) {
        Date date = new Date();
        try {
            date = meetDateTimeFormat.parse(strDate);
        } catch (Exception e){

        }
        return commonLongDateFormatForChinese1.format(date);

    }


    /**
     * 计算两个日期之间相差的天数
     * @param smdate 较小的时间
     * @return 相差天数
     * @throws ParseException
     */
    public static int daysBetween(Date smdate) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(smdate);
        long time1 = cal.getTimeInMillis();
        cal.setTime(new Date());
        long time2 = cal.getTimeInMillis();
        long between_days = (time2-time1)/(1000*3600*24);
        return Integer.parseInt(String.valueOf(between_days));
    }
    
    /**
     * 获取当前日期是星期几<br>
     * 
     * @param dt
     * @return 当前日期是星期几
     */
    public static String getWeekOfDate(Date dt) {
        String[] weekDays = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"};
        Calendar cal = Calendar.getInstance();
        cal.setTime(dt);
        int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if (w < 0)
            w = 0;
        return weekDays[w];
    }    
    
    /**
     * 将长时间格式时间转换为 html5 字符串 yyyy-MM-dd HH:mm:ss
     * 
     * @param dateTime
     * @return
     */
    public static String dateTimeToH5() {
        return commonDateTimeFormat.format(new Date());
    }
    
    public static String renterSMS(long time){
    	return commonLongDateFormatForChinese1.format(new Date(time));
    }
    

    public static void main(String args[]) throws ParseException {
    	System.out.println(DateUtil.renterSMS(System.currentTimeMillis()));
    	/*
    	Calendar cal = Calendar.getInstance();
    	cal.add(Calendar.DATE, 1- cal.get(Calendar.DAY_OF_WEEK)+1);
    	
    	
    	cal.set(Calendar.HOUR_OF_DAY, 0);
    	cal.set(Calendar.MINUTE, 0);
    	cal.set(Calendar.SECOND, 0);
    	System.out.println(DateUtil.meetDateTimeFormat.format(cal.getTime()) );
    	
    	cal.add(Calendar.DATE, 7);
    	System.out.println(DateUtil.meetDateTimeFormat.format(cal.getTime()) );
        System.out.println(cal.get(Calendar.DAY_OF_WEEK));
    	
    	
        /*
        Date date1 = meetDateTimeFormat.parse("2015-11-01 02:22");
        long time = new Date().getTime() - date1.getTime();
        System.out.print(time/(1000*60*60));
        */
        /*
        ParsePosition pos = new ParsePosition(0);
        Date date = meetDateTimeFormat.parse("2015-09-15 2:22", pos);
        System.out.print(commonLongDateFormatForChinese1.format(date)); ;
        */
       // System.out.print(dateToString2("2015-09-15 09:22"));
        //Date date = new Date("2015-04-15 19:22:18");
        //Calendar cal = Calendar.getInstance();
        //int month = cal.get(Calendar.MONTH);//获取月份
        //int month = cal.get(Calendar.MONTH);//获取月份
        //System.out.println(getStringNextMonth(new Date(), 4));


    }
}